<template>
  <div>
    <el-dialog :title="title" :closeOnClickModal="false" :visible.sync="show" width="650px">
      <el-form label-position="right" :model="selectTable" ref="addForm" label-width="80px" :inline="false" autocomplete="off">
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名">{{selectTable.accountHolder}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="单号">{{selectTable.withdrawalNumber}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="提现方式">{{selectTable.payTypeName}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="状态">{{selectTable.withdrawalDisposeStatusName}}</el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="账号">{{selectTable.withdrawalAccount}}</el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="提现金额">{{selectTable.withdrawalRMBAmount}}</el-form-item>
          </el-col>
        </el-row>
        <el-form-item v-for="(item, index) in selectTable.withdrawalDetailList" :label="item.withdrawalDisposeStatusName" :key="index">{{item.createTime | parseTime('{y}-{m}-{d} {h}:{i}:{s}')}}</el-form-item>
        <el-form-item label="失败原因" v-if="selectTable.remark.length">{{selectTable.remark}}</el-form-item>
        <el-row :gutter="20" v-if="selectTable.withdrawalDisposeStatus === 1||selectTable.withdrawalDisposeStatus === 2">
          <el-col>
            <el-form-item label="审核" :rules="[{required: true, message: '必填项', trigger: 'change'}]">
              <el-radio v-model="selectTable.curStatus" :label="0">审核通过</el-radio>
              <el-radio v-model="selectTable.curStatus" :label="1">审核未通过</el-radio>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20" v-if="selectTable.curStatus === 1">
          <el-col>
            <el-form-item label="审核不通过原因" prop="curRemark" :rules="[{required: true, message: '必填项', trigger: 'change'}]">
              <el-input type="textarea" placeholder="请输入" v-model="selectTable.curRemark" maxLength="200"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="show = false">关闭</el-button>
        <el-button @click.native="auditEvent" type="primary" v-if="selectTable.withdrawalDisposeStatus === 1||selectTable.withdrawalDisposeStatus === 2">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import * as api from '@/utils/api'
export default {
  components: {
  },
  props: {
    data: Object
  },
  data () {
    return {
      status: null
    }
  },
  created () {
    this.selectTable = this.JSONs(this.data)
  },
  watch: {
    show (newVal) {
      this.$emit('close')
    }
  },
  computed: {
    title () {
      return '查看'
    }
  },
  data () {
    return {
      show: true,
      selectTable: {}
    }
  },
  methods: {
    async auditEvent () {
      try {
        if(this.selectTable.curStatus === 1&&!this.selectTable.curRemark.length) {
          this.$notify({ title: '请输入审核不通过原因', type: 'warming', duration: 2000 })
          return false
        }
        await api.updateLtsWithdrawal({
          withdrawalId: this.selectTable.withdrawalId,
          operateStatus: this.selectTable.curStatus,
          remark: this.selectTable.curRemark
        })
        this.$notify({ title: '操作成功', type: 'success', duration: 2000 })
        this.show = false
      } catch (e) {
        console.log(e)
      }

    }
  }
}
</script>
